package org.playground.booking.dao.impl;

import org.hibernate.query.Query;
import org.playground.booking.dao.IWechatMerchantAccountDao;
import org.playground.booking.entity.WechatMerchantAccount;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by root on 17-10-28.
 */
@Repository
public class WechatMerchantAccountDaoImpl extends AbstractDaoImpl<WechatMerchantAccount,Long> implements IWechatMerchantAccountDao {
    public WechatMerchantAccount readByAppId(String appid){
        String hql ="from WechatMerchantAccount as account " +
                "where appid =:appid";
        Query query = this.getCurrentSession().createQuery(hql);

        query.setParameter("appid",appid);

        List<WechatMerchantAccount> result = query.list();

        return result.size()==0?null:result.get(0);
    }
}
